package com.exercise.family

import com.alibaba.fastjson.JSONObject
import com.fun.frame.httpclient.FanLibrary
import com.fun.utils.RString

class TestUser extends FunBase {

    static String content = "/user"

    static TestUser drive = new TestUser()

    public JSONObject find() {
        String url = content + "/get"
        def params = new JSONObject()
        params.put("uid", 393)
        params.put("envId", "")
        params.put("pageNum", 1)
        params.put("pageSize", 5)
        params.put("roleId", "")
        params.put("status", "")
        params.put("query", "")
        params.put("type", "")
        def response = getGetResponse(url, params)
        output(response)
    }

    public JSONObject add() {
        String url = content + "/edit"
        JSONObject params = new JSONObject();
        params.put("uid", 763);
        String uanme = "81951380694"
        params.put("user", uanme);
        params.put("password", uanme);
        params.put("phone", 1232323);
        params.put("roleId", 1);
        params.put("envId", 1);
        params.put("des", "测试" + RString.getString(20));
        params.put("type", "add");
        def response = getPostResponse(url, params)
        output(response)
    }

    public JSONObject update() {
        String url = content + "/edit"
        JSONObject params = new JSONObject();
        params.put("id", 1038);
        params.put("uid", 1003);
        params.put("user", getRandomIntRange(10000, 99999));
        params.put("password", 1232323);
        params.put("phone", 1232323);
        params.put("roleId", 3);
        params.put("envId", getRandomInt(4));
        params.put("dec", "测试" + RString.getString(20));
        params.put("type", "update");
        def response = getPostResponse(url, params)
        output(response)
    }

    public JSONObject del() {
        String url = content + "/del"
        JSONObject params = new JSONObject();
        params.put("id", 1044);
        params.put("uid", 1007);
        def response = getPostResponse(url, params)
        output(response)
    }

    public JSONObject test() {
        String url = content + "/test"
        JSONObject params = new JSONObject();
        params.put("id", 1034);
        params.put("uid", 1003);
        params.put("user", getRandomIntRange(10000, 99999));
        params.put("password", 1232323);
        params.put("phone", 1232323);
        params.put("status", 2);
        params.put("roleId", 3);
        params.put("envId", getRandomInt(4));
        params.put("dec", "测试" + DEFAULT_STRING);
        params.put("certificate", DEFAULT_STRING);
        def response = getPostResponse(url, params)
        output(response)
    }

    public static void main(String[] args) {
        drive.find()
//        drive.update()
//        drive.add()
//        drive.del()
//        drive.test()
//        drive.find()

//        drive.add()


        FanLibrary.testOver()
    }

}
